package com.laozhao.deliveryManager.test;
import jp.ne.so_net.ga2.no_ji.jcom.IDispatch;
import jp.ne.so_net.ga2.no_ji.jcom.JComException;
import jp.ne.so_net.ga2.no_ji.jcom.ReleaseManager;
public class PrintDocument {
    /***
    * 
    * @param docApplication Application类型
     * @param docProperty  文档的属性
     * @param filePath 文件的绝对路径
     */
	public void print(String docApplication,String docProperty,String filePath){
        ReleaseManager rm = new ReleaseManager();
        try {
            IDispatch docApp = new IDispatch(rm, docApplication);
            docApp.put("Visible", new Boolean(false));
            IDispatch wdDocuments = (IDispatch) docApp.get(docProperty);
            Object[] arglist1 = new Object[1];
            
            arglist1[0] = (Object)filePath;
            IDispatch docDocument = (IDispatch) wdDocuments.method("Open",
                    arglist1);
            
            docDocument.method("PrintOut", null);
            docApp.method("Quit", null);
        }catch(JComException e){
            e.printStackTrace();
        }
        
        rm.release();
        rm = null;
    }
    /**
     * @param args
     */
	public static void main(String[] args) {
        // TODO Auto-generated method stub 
        PrintDocument pd = new PrintDocument();
        String path="e://test.doc";
        
        pd.print("Word.Application", "Documents", path);
        //String path="e://test.xls"; 45.        
        //pd.print("Excel.Application", "Workbooks", path);
         }
}